package com.lyn.solitude_plugin;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewbinding.ViewBinding;

/**
 * @author longyn 2024/4/14
 * @version 1.0.0
 */
public abstract class BaseActivity<V extends ViewBinding> extends AppCompatActivity {

    public V binding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = getViewBinding();
        setContentView(binding.getRoot());
    }

    public abstract V getViewBinding();

    public void jump(Class<? extends Activity> activityClass) {
        jump(activityClass, true);
    }

    public void jump(Class<? extends Activity> activityClass, boolean finish) {
        startActivity(new Intent(this, activityClass));
        if (finish) {
            finish();
        }
    }
}
